export const useMapExport = (map) => {
  const imageExport = () => {
    map.value.once("postcompose", function (event) {
      var canvas = event.context.canvas
      canvas.toBlob(function (blob) {
        saveAs(blob, "map.png")
      })
    })
    map.value.renderSync()
  }
  const pdfExport = () => {
    map.value.once("postcompose", function (event) {
      var canvas = event.context.canvas
      var data = canvas.toDataURL("image/jpeg")
      var pdf = new jsPDF("landscape", undefined)
      pdf.addImage(data, "JPEG", 0, 0)
      pdf.save("map.pdf")
    })
    map.value.renderSync()
  }
  return { imageExport, pdfExport }
}
